package com.lris.handle;


import cn.hutool.core.date.DateUtil;
import com.lris.pojodata.Message;
import com.lris.rest.Result;
import com.lris.server.ImServer;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;

/**
 * 群聊
 */
@Slf4j
public class JoinHandle {
    public static void execute(ChannelHandlerContext ctx) {
        ImServer.GROUP.add(ctx.channel());
        Message message = new Message();
        message.setAddTime(DateUtil.date().toLocalDateTime());
        message.setAddNickname("聚义厅");
        message.setRemark("这是一个齐聚天下英雄的聚义厅");
        message.setToId(9999L);  //9999L代表去聚义厅
        message.setPhone("歃血为盟");
        message.setHeadImg("https://ts1.cn.mm.bing.net/th/id/R-C.d8066bc7f6837cac1f3d72a061140b8d?rik=K00hTcMojzosww&riu=http%3a%2f%2fpic.ntimg.cn%2ffile%2f20161222%2f2290814_034208424000_2.jpg&ehk=0qPXNQurrdn5oFLMjpU4gTpaRBDJ4DIMiJYWnmpwLZ8%3d&risl=&pid=ImgRaw&r=0");
        message.setMsgType(3);
        log.info("已加入群组");
        ctx.writeAndFlush(Result.success(message));

    }
}
